//
//  HomeRecommendQuickIntoView.swift
//  HomeRecommendQuickIntoView
//
//  Created by Ben on 2021/8/19.
//

import SwiftUI

struct HomeRecommendQuickIntoView: View {
    
    
    var body: some View {
        LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 0), count: 3), spacing: 4) {
            
            ForEach(HOME_RECOMMEND_QUICKINTO_MODELS) { model in
                HomeRecommendQuickIntoItemView(model: model)
            }
        }
        .frame(maxWidth: .infinity)
    }
}

struct HomeRecommendQuickIntoItemView: View {
    
    var model: HomeRecommendQuickIntoModel
    
    var body: some View {
        
        ZStack(alignment: .trailing) {
            Image(model.iconName)
                .resizable()
                .aspectRatio(contentMode: .fit)
                .padding(4)
                .frame(width: 50, height: 50, alignment: .trailing)
            
            VStack(alignment: .leading, spacing: 4) {
                Text(model.title)
                    .font(.system(size: 15))
                    .fontWeight(.semibold)
                Text(model.subTitle)
                    .font(.system(size: 12))
                    .foregroundColor(Color(hex: model.subTitleColor))
            }
            .frame(maxWidth: .infinity, alignment: .leading)
            
        }
        .padding(.horizontal, 8)
    }
}

struct HomeRecommendQuickIntoView_Previews: PreviewProvider {
    
    static var previews: some View {
        HomeRecommendQuickIntoView()
    }
}
